# -*- coding: UTF-8 -*-
# __author__ = '10459'
from app.view_models.book import BookViewModel

# class MyGifts:
#     def __init__(self,gifts_of_mine,wish_count_list):
#         self.gifts=[]
#         self.__gifts_of_mine= gifts_of_mine
#         self.__wish_count_list = wish_count_list
#         #不建议在自己内部的函数中去改变属性的值，可以查询读取，可以通过函数调用增加中间参数如temp_gifts等，改变后然后作为返回值再赋值给属性
#         #不然不知道哪个属性在哪个方法被修改
#         self.gifts = self.__parse()
#     def __parse(self):
#         temp_gifts=[]
#         for gift in self.__gifts_of_mine:
#             my_gift = self.__matching(gift)
#             temp_gifts.append(my_gift)
#         return temp_gifts
#     def __matching(self,gift):
#         count=0
#         for wish_count in self.__wish_count_list:
#             if gift.isbn==wish_count["isbn"]:
#                 count= wish_count["count"]
#
#         my_gift={
#             "id":gift.id,
#             "book":BookViewModel(gift.book),
#             "wishes_count":count
#         }
#
#         return my_gift
# from collections import namedtuple

# MyGift = namedtuple("MyGift",["id","book","wishes_count"]) #属性
#
# class MyGifts:
#     def __init__(self,gifts_of_mine,wish_count_list):
#         self.gifts=[]
#         self.__gifts_of_mine= gifts_of_mine
#         self.__wish_count_list = wish_count_list
#         self.__parse()
#     def __parse(self):
#         for gift in self.__gifts_of_mine:
#             my_gift = self.__matching(gift)
#         self.gifts.append(my_gift)
#     def __matching(self,gift):
#         count=0
#         for wish_count in self.__wish_count_list:
#             if gift.isbn==wish_count["isbn"]:
#                 count= wish_count["count"]
#         my_gift = MyGift(gift.id,BookViewModel(gift.book),count)
#         return my_gift